<?php  if (!defined('INSTALL')) exit('No direct script access allowed');

function check_complete_install()
{
	$config_path = './../application/config/';
	
	// File created?
	if (file_exists($config_path.'sp_database') )
	{
		include($config_path.'sp_database');
		
		// File contents valid?
		if (is_array($db['default']));
		{
			$db = $db['default'];
			
			// Database Server Accessible
			if ( $connection = @mysql_connect($db['hostname'], $db['username'], $db['password']) )
			{
				// Database Exists
				if ( mysql_select_db($db['database'], $connection) )	
				{
					// That does it, this thing is already installed
					if ( $result = mysql_query("SELECT * FROM users") )
						return TRUE;
				}
				mysql_close($connection);
			}
		}
	}
	return FALSE;
}


function increment_step($cur_step)
{
	$steps = array('welcome', 'license', 'server', 'database', 'user', 'complete');
	
	$current = array_search($cur_step, $steps);
	$highest = array_search($sess_step, $steps);
	
	if ($current > $highest)
	{
		$_SESSION['step'] = $steps[$current];
	}
}

?>